package org.chengn.level_easy.context2660;

/**
 * @Title: Context70
 * @Author ChengN
 * @Package org.chengn.level_easy.context2660
 * @Date 2023/12/27 08:57
 * @description 保龄球游戏的获胜者
 */
public class Context2660 {
    public int isWinner(int[] player1, int[] player2) {
        int val1 = val(player1), val2 = val(player2);
        if (val1 > val2) return 1;
        if (val1 < val2) return 2;
        return 0;
    }

    int val(int[] ans) {
        int tenTimes = 0;
        int res = 0;
        for (int an : ans) {
            if (tenTimes > 0) {
                res += 2 * an;
                tenTimes--;
            } else {
                res += an;
            }
            tenTimes = an == 10 ? 2 : tenTimes;
        }
        return res;
    }
}
